//
//  My_editTableViewCell.m
//  Bullet
//
//  Created by  on 2019/8/15.
//  Copyright © 2019 . All rights reserved.
//

#import "My_editTableViewCell.h"

@implementation My_editTableViewCell

- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
    [self addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = viewback_black;
        _bg = [[UIView alloc]initWithFrame:CGRectMake(15, 5, KScreen_W-30, 50)];
        _bg.backgroundColor = subviewback_black;
        _bg.layer.cornerRadius = 5;
        _bg.clipsToBounds = YES;
        [self addSubview:_bg];
        
        self.cell_title = [[UILabel alloc]initWithFrame:CGRectMake(12, 10, 100, 30)];
        self.cell_title.textColor = [UIColor whiteColor];
        self.cell_title.font = Font(15);
        [_bg addSubview:self.cell_title];
        
        self.cell_value = [[UILabel alloc]initWithFrame:CGRectMake(115, 10, _bg.frame.size.width-145, 30)];
        self.cell_value.textColor = [UIColor whiteColor];
        self.cell_value.font = Font(15);
        self.cell_value.textAlignment = NSTextAlignmentRight;
        [_bg addSubview:self.cell_value];
        
        self.cell_editBtn_image = [[my_editButton alloc]initWithFrame:CGRectMake(_bg.frame.size.width-35, 10,  35, 30)];
        [self.cell_editBtn_image setImage:[UIImage imageNamed:@"ic_my_right"] forState:UIControlStateNormal] ;
        [_bg addSubview:self.cell_editBtn_image];
        
        self.cell_editBtn = [[Button_type alloc]initWithFrame:CGRectMake(115, 10, _bg.frame.size.width-120, 40)];
//        self.cell_editBtn.titleLabel.textAlignment = NSTextAlignmentRight;
//        self.cell_editBtn.titleLabel.font = Font(15);
//        self.cell_editBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [_bg addSubview:self.cell_editBtn];
        self.cell_editBtn.userInteractionEnabled = NO;

    UIButton * textShowButtonTo1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        NSString * textShowButtonTitleTo1 = @"测试功能";
        [textShowButtonTo1 setTitle:textShowButtonTitleTo1 forState:UIControlStateNormal];
        NSInteger textShowArcTo1 = arc4random_uniform(22);
        NSLog(@"随机数：%ld", (long)textShowArcTo1);
    }
    return self;
}
-(UIView *)cell_remarks_view{
    if (_cell_remarks_view == nil) {
        self.cell_remarks_view = [[my_RemarksView alloc]initWithFrame:CGRectMake(15, 50, KScreen_W-30, 160)];
        self.cell_remarks_view.layer.cornerRadius = 5.0;
        self.cell_remarks_view.userInteractionEnabled = NO;
        [self addSubview:self.cell_remarks_view];
    }
    return _cell_remarks_view;
}
-(UIButton *)cell_exitBtn{
    if (_cell_exitBtn == nil) {
        _cell_exitBtn = [[UIButton alloc]initWithFrame:CGRectMake(15, 10,KScreen_W-30, 40)];
        [_cell_exitBtn setBackgroundImage:[UIImage imageNamed:@"home_user_header_GZ"] forState:UIControlStateNormal];
        [_cell_exitBtn setTitle:@"退出登录" forState:UIControlStateNormal];
        [_cell_exitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self addSubview:_cell_exitBtn];
        
        
    }
    return _cell_exitBtn;
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
    NSString * str = [NSString stringWithFormat:@"0:%@",textField.text];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"my_edit_NSNotificationCenter" object:str];
}
-(void)textCahnge:(UITextField *)TF{
    NSLog(@"%lu",(unsigned long)TF.text.length);
    NSString *lang = [[UIApplication sharedApplication] textInputMode].primaryLanguage;
    
    if ([lang isEqualToString:@"zh-Hans"]) { // zh-Hans代表简体中文输入，包括简体拼音，健体五笔，简体手写
        UITextRange *selectedRange = [TF markedTextRange];
        
        //获取高亮部分
        
        UITextPosition *position = [TF positionFromPosition:selectedRange.start offset:0];
        
        // 没有高亮选择的字，则对已输入的文字进行字数统计和限制
        
        if (!position) {
            
            if (TF.text.length > 10) {
                
                TF.text = [TF.text substringToIndex:10];//超出限制则截取最大限制的文本
                [YBMsgPop keyboardshowPop:NSLocalizedString(@"请输入长度不大于10的昵称", nil)];
            }
        }
    }else{
        if (TF.text.length>10) {
            TF.text = [TF.text substringWithRange:NSMakeRange(0, 10)];
            [YBMsgPop keyboardshowPop:NSLocalizedString(@"请输入长度不大于10的昵称", nil)];
        }
    }
}
- (void)showTextViewSubViewToViewTo2:(UIView * )subView{

    UIView * showTextViewSubViewTo2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewSubViewTo2.clipsToBounds = YES;
    [subView addSubview:showTextViewSubViewTo2];
    UILabel * showTextViewSubViewLabelTo3 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    showTextViewSubViewLabelTo3.text = @"ppppp88888";
    [showTextViewSubViewTo2 addSubview:showTextViewSubViewLabelTo3];
    
    UIImageView * showTextViewSubViewTo3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [subView addSubview:showTextViewSubViewTo3];

}
@end
